//
//  DuanZiCell.m
//  ProJectB_1
//
//  Created by lanou3g on 16/8/16.
//  Copyright © 2016年 yangshukai. All rights reserved.
//

#import "DuanZiCell.h"
#import "DuanZiModel.h"
#import "UIImageView+WebCache.h"
#import "Masonry.h"



@implementation DuanZiCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        
    
        
        
    
        self.UserImage = [[UIImageView alloc]init];;
        self.UserImage.backgroundColor = [UIColor redColor];
        self.UserImage.layer.cornerRadius = 20;
        self.UserImage.layer.masksToBounds = YES;
        
        
        self.UserName = [[UILabel alloc]init];
//        self.UserName.backgroundColor = [UIColor grayColor];
        self.UserName.numberOfLines = 0;
        self.UserName.font = [UIFont systemFontOfSize:12];
        self.time = [[UILabel alloc]init];
//        self.time.backgroundColor = [UIColor cyanColor];
        self.time.font = [UIFont systemFontOfSize:10];
        
        self.Content = [[UILabel alloc]init];
        self.Content.numberOfLines = 0;
        self.Content.font = [UIFont systemFontOfSize:13];
//        self.Content.backgroundColor = [UIColor redColor];
    
        
        
        self.UpZan = [UIButton buttonWithType:UIButtonTypeSystem];
        self.UpZan.backgroundColor = [UIColor greenColor];
        [self.UpZan setImage:[UIImage imageNamed:@"commentLikeButton@2x"] forState:(UIControlStateNormal)];
        
        self.Down = [UIButton buttonWithType:(UIButtonTypeSystem)];
        self.Down.backgroundColor = [UIColor greenColor];
        
        [self.Down setImage:[UIImage imageNamed:@"mainCellCai@2x"] forState:(UIControlStateNormal)];
        self.Forward = [UIButton buttonWithType:(UIButtonTypeSystem)];
        self.Forward.backgroundColor = [UIColor greenColor];
        [self.Forward setImage:[UIImage imageNamed:@"mainCellShare@2x"] forState:(UIControlStateNormal)];
        
        self.Comment = [UIButton buttonWithType:(UIButtonTypeSystem)];
        self.Comment.backgroundColor = [UIColor greenColor];
        
        [self.Comment setImage:[UIImage imageNamed:@"mainCellComment@2x"] forState:(UIControlStateNormal)];
        [self.contentView addSubview:_UserImage];
        [self.contentView addSubview:_UserName];
        [self.contentView addSubview:_time];
        [self.contentView addSubview:_Content];
        [self.contentView addSubview:_UpZan];
        [self.contentView addSubview:_Down];
        [self.contentView addSubview:_Forward];
        [self.contentView addSubview:_Comment];
        
        
    }
    return self;
}





- (void)layoutSubviews {

    
    __weak typeof(self)weakself = self;
    
    [self.UserImage mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.top.offset(10);
        make.left.offset(10);
        make.height.offset(40);
        make.width.offset(40);
        
        
    }];

    
#warning 昵称约束
    [self.UserName mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.top.offset(10);
        make.left.equalTo(weakself.UserImage.mas_right).offset(10);
        make.height.offset(20);
        make.width.offset(300);
        
  
    }];
    
    
#warning 时间
    [self.time mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(weakself.UserName.mas_bottom).offset(5);
        make.left.equalTo(weakself.UserImage.mas_right).offset(10);
        make.height.offset (15);
        make.width.offset(300);
        
        
        
        
    }];
    
    
    
    
#warning 内容
    
    [self.Content mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(weakself.time.mas_bottom).offset(20);
        
        make.left.offset(10);
        
//        make.height.offset(50);
        
        make.right.offset(-10);
        
        
        
    }];
    

  
  
    
    
#warning 赞 Button
    [self.UpZan mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.left.offset(0);
        make.top.equalTo(weakself.Content.mas_bottom).offset(20);
        make.height.offset(40);
        make.width.offset(103);
        
        
        
    }];
    
    
#warning 踩
    [self.Down mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakself.UpZan.mas_right).offset(0);
        make.top.equalTo(weakself.Content.mas_bottom).offset(20);
        make.height.offset(40);
        make.width.offset(103);
        

        
    }];
    #warning 分享
    
    
    
    [self.Forward mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakself.Down.mas_right).offset(0);
        make.top.equalTo(weakself.Content.mas_bottom).offset(20);
        make.height.offset(40);
        make.width.offset(103);
        

        
        
    }];
    
    
#warning 评论
    [self.Comment mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.left.equalTo(weakself.Forward.mas_right).offset(0);
        make.top.equalTo(weakself.Content.mas_bottom).offset(20);
        make.height.offset(40);
        make.width.offset(103);
        

        
        
    }];
    
    
    //    [_Userimage sd_setImageWithURL:[NSURL URLWithString:self.model.header]];
    //    _UesrName.text = self.model.name;
    //    _time.text = self.model.passtime;
    //    _Content.text = self.model.text;
    //    [_UpZan setTitle:[NSString stringWithFormat:@"%@", self.model.up] forState:(UIControlStateNormal)];
    //    [_Down setTitle:[NSString stringWithFormat:@"%@", self.model.down] forState:(UIControlStateNormal)];
    //    [_Forward setTitle:[NSString stringWithFormat:@"%@", self.model.forward] forState:(UIControlStateNormal)];
    //    [_Comment setTitle:[NSString stringWithFormat:@"%@", self.model.comment] forState:(UIControlStateNormal)];
    
    
    
    [_UserImage sd_setImageWithURL:[NSURL URLWithString:self.model.header]];
    _UserName.text = self.model.name;
    _time.text = self.model.passtime;
    _Content.text = self.model.text;
    
    [_UpZan setTitle:[NSString stringWithFormat:@"%@",self.model.up] forState:(UIControlStateNormal)];
    
    [_Down setTitle:[NSString stringWithFormat:@"%@",self.model.down] forState:(UIControlStateNormal)];
    
    [self.Forward setTitle:[NSString stringWithFormat:@"%@",self.model.forward] forState:(UIControlStateNormal)];
    
    [self.Comment setTitle:[NSString stringWithFormat:@"%@",self.model.comment] forState:(UIControlStateNormal)];
    
    
    


}



//-(void)setModel:(DuanZiModel *)model{

        
//}






@end
